# -*- coding: utf-8 -*-
import aiomysql
from tornado import ioloop

async def select_db():
    async with await aiomysql.create_pool(
        host='127.0.0.1', port=3306, user='root', password='root', db='test'
    ) as pool:
        async with pool.acquire() as conn:
            async with conn.cursor() as cur:
                await cur.execute("select * from users;")
                tmp = await cur.fetchone()
                print(tmp) # (1, 'zhangwei', '123456')

if __name__ == '__main__':
    ioloop.IOLoop.current().run_sync(select_db)


